package com.itheima.controller;

import com.itheima.common.entity.Result;
import com.itheima.pojo.Order;
import com.itheima.pojo.SubmitOrder;
import com.itheima.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    //根据预约id查询预约信息
    @GetMapping("/findById")
    public Result findById(String id) {
        Order order = orderService.findById(id);
        return new Result(true, "查询预约信息成功", order);
    }

    //提交预约
    @PostMapping("/submitOrder")
    public Result submitOrder(@RequestBody SubmitOrder submitOrder) {
        Integer num = orderService.submitOrder(submitOrder);
        return new Result(true, "预约成功",num);
    }

}
